package com.wehealth;


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;
import android.support.v4.app.Fragment;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.AdapterView.OnItemClickListener;

import com.umeng.analytics.MobclickAgent;
import com.wehealth.Dr_List;
import com.wehealth.Dr_Free;
import com.wehealth.adapter.Adapter_QuestionList;
import com.wehealth.dm.QuestionData;

public class Health_search_Select extends Fragment {
	
   private static final int DISEACE = 1;
   private static final int FOOD = 2;
   private static final int SPORT =3;
	private MainActivity context;
	
	public  Health_search_Select()
	{
		Log.i("init:", "test"); 
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		return  inflater.inflate(R.layout.health_search_select, null);
	}
	
	public void onActivityCreated(Bundle savedInstanceState){
		
		super.onActivityCreated(savedInstanceState);
		
		Log.i("OnActivityCreated:", "test"); 
		
		MainActivity activity = (MainActivity)getActivity();
		context = activity;
		MobclickAgent.openActivityDurationTrack(false);
		Button bBack = (Button) activity.findViewById(R.id.b_back);
			
		 bBack.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{
					
                    MainActivity activity = (MainActivity) getActivity();                       
                    activity.switchContentHome();
				}
			});
		 
		 
		 Button bSel1 = (Button) activity.findViewById(R.id.health_diseace_Select1);
			
		 bSel1.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{

					
				}
			});
		 
		 Button bSel2 = (Button) activity.findViewById(R.id.health_food_Select2);
			
		 bSel2.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{
				    entryNextScreen(FOOD);
				}
			});
		 
		 Button bSel3 = (Button) activity.findViewById(R.id.health_sports_Select3);
			
		 bSel3.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{
		            Log.d("SIMMON","  health_food_Select2  ");
		            entryNextScreen(SPORT);
					
				}
			});
			
		
	}
	
	private void openDialog(){
		
	    AlertDialog.Builder builder = new AlertDialog.Builder(context);    
	    builder.setTitle("功能暂时没有开通！");  
	    builder.setPositiveButton("知道了",null);
	    builder.show();  
		
	}
	
    @Override
    public void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        MobclickAgent.onPageEnd("Health_search_Select"); 
    }


    @Override
    public void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        MobclickAgent.onPageStart("Health_search_Select"); 
    }

    
    private void entryNextScreen(int index){
        Health_search_Select2 mNextScreen = new Health_search_Select2();
        mNextScreen.setDisplayItem(index);
        context.switchContent(mNextScreen);
    }
}
